********************************************************************************
********************************************************************************
* PROGRAM:		sample_restrictions
* Project:		Stress, Ethnicity, and Prosocial Behavior
* Author:		Moritz Poll (moritz.poll@brown.edu)
* PIs:			Johannes Haushofer, Sara Lowes, Abednego Musau, David Ndetei, 
*				Nathan Nunn, Moritz Poll, Nancy Qian
* Purpose:		Takes a sample restriction or fixed effects code and translates
*				it into locals for regression and table design
********************************************************************************
********************************************************************************

$noisyregs dis "Implementing sample restriction `rest'"
local fe = ""
local if_restriction ""
local cluster cluster(ID)
local x "eth"
if "`rest'" == "_coa07" { // 2007 Coalition
	local x "coa07"
}
if "`rest'" == "_coa17" { // 2017 Coalition
	local x "coa17"
}
if "`rest'" == "_sessionfe" { // Session FEs
	if `spec' == 2 continue
	local fe "i.session"
}
if "`rest'" == "_first_same" {
	local if_restriction "if mothertongue_first_same == 1"
	if "`game'" == "cyd" continue
}
if "`rest'" == "_first_diff" {
	local if_restriction "if mothertongue_first_same == 0"
	if "`game'" == "cyd" continue
}
if "`rest'" == "_parents_same" {
	local if_restriction "if tribe_identity == 1"
}
if "`rest'" == "_low_edu" {
	local if_restriction "if pool_secondary == 1"
}
if "`rest'" == "_high_edu" {
	local if_restriction "if pool_secondary == 0"
}
if "`rest'" == "_firstround" {
	if `spec' == 2 continue // One obs per person does not work with individual fixed effects
	local if_restriction "if round == 1"
}
if "`rest'" == "_comprehension" {
	if "`game'" == "social_proximity" local if_restriction "if total_incorrect_answers < 0.5" // No comprehension questions for social proximity; use overall comprehension instead.
	else local if_restriction "if _incorrect_answers < 0.5"
}
if "`rest'" == "_viewtime" {
	local if_restriction "if _viewtime_rank > 0.2"
}
if "`rest'" == "_decisiontime" {
	local if_restriction "if _decisiontime_rank > 0.2"
}
if "`rest'" == "_continuetime" {
	local if_restriction "if _continuetime_rank > 0.2"
}
if "`rest'" == "_imbalance" {
	if "`game'" == "cyd" continue // These would not be identified
	local if_restriction "kikuyu pool_college pool_assets_pca" // Adding controls to the regression
}
if "`rest'" == "_welsch" {
	local if_restriction "if welsch_drop == 0"
}
